package com.lovo.csc.controller;


import com.lovo.csc.entity.Offerinfo;
import com.lovo.csc.service.IOfferinfoService;
import com.lovo.psc.service.IPscUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-07-13
 */
@RestController
@RequestMapping("/offerinfo")
@Api(tags = "报价审核控制层--舒得强")
public class OfferinfoController {
    @Autowired
    IOfferinfoService offerinfoService;
    @Autowired
    IPscUserService pscUserService;

    @DeleteMapping("delTender/{purchasetenderCode}")
    @ApiOperation(value = "取消采购")
    public boolean delTender(@PathVariable("purchasetenderCode") int purchasetenderCode){
        pscUserService.del(purchasetenderCode);
        return true;
    }
    @GetMapping("findAll")
    @ApiOperation("查询出报价表的数据")
    public List<Offerinfo> findAll(){
        return offerinfoService.list();

    }
    @PostMapping("OfferInfo/{purchasetenderCode}/{supplierId}")
    @ApiOperation("返回中标信息")
    public boolean OfferInfo(@PathVariable("purchasetenderCode") int purchasetenderCode, @PathVariable("supplierId") int supplierId){
        pscUserService.upDateNumStateBy(purchasetenderCode,supplierId);
        return true;
    }

    @PutMapping("UpdateOfferState/{offerId}/{state}")
    @ApiOperation(value = "修改报价状态")
    public boolean UpdateOfferState(@PathVariable("offerId") int offerId,@PathVariable("state") String state){
        offerinfoService.updateOfferState(offerId,state);
        return true;
    }
}
